﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Catsland.Core;
using System.ComponentModel;

namespace Catsland.CatsPlugin
{
	public class SelfDestroyer : CatComponent
	{
		int m_timeElipse = 0;
		
        public int m_time = 1000;
        [CategoryAttribute("Behavior")]
        public int LifeTime
        {
            get { return m_time; }
            set { m_time = value; }
        }

		public SelfDestroyer(GameObject gameObject)
			: base(gameObject)
		{

		}

		public override void Update(int timeLastFrame)
		{
			base.Update(timeLastFrame);
			m_timeElipse += timeLastFrame;
			if (m_timeElipse > m_time)
			{
				Mgr<Scene>.Singleton._gameObjectList.RemoveItem(m_gameObject._guid);
			}
		}

        public override void ConfigureFromNode(System.Xml.XmlElement node, Scene scene, GameObject gameObject)
        {
            base.ConfigureFromNode(node, scene, gameObject);
        }

	}
}
